package cn.mengfly.testnrz.im.client.sender;

import cn.mengfly.testnrz.im.ProtoMsg;
import cn.mengfly.testnrz.im.client.bean.ChatMsg;
import cn.mengfly.testnrz.im.client.builder.ChatMsgBuilder;

public class ChatSender extends BaseSender {

    public void sendChatMsg(String toUid, String content) {
        System.out.println("发送信息");
        ChatMsg chatMsg = new ChatMsg(getUser());
        chatMsg.setContent(content);
        chatMsg.setMsgType(ChatMsg.MsgType.TEXT);
        chatMsg.setTo(toUid);
        chatMsg.setMsgId(System.currentTimeMillis());
        ProtoMsg.Message message = ChatMsgBuilder.buildChatMsg(chatMsg, getUser(), getSession());
        super.sendMsg(message);
    }

    @Override
    protected void sendSuccess(ProtoMsg.Message message) {
        System.out.println("发送成功:" + message.getMessageRequest().getContent());
    }

    @Override
    protected void sendFailed(ProtoMsg.Message message) {
        System.out.println("发送失败:" + message.getMessageRequest().getContent());
    }
}
